﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TongHopBookFlightDAO.DAO
{
    public class GiaVeDAO
    {
        public static int Insert(GiaVe _obj)
        {
            int ID = -1;
            try
            {
                BookFlightDataContext context = new BookFlightDataContext();
                context.GiaVes.InsertOnSubmit(_obj);
                context.SubmitChanges();
                ID = _obj.GiaVeID;
            }
            catch { }
            return ID;
        }

        /// <summary>
        ///  Lấy tất cả các giá vé của chuyên bay ID
        /// </summary>
        /// <param name="flightID">Chuyến bay ID</param>
        public static List<GiaVe> SelectByFlightID(int chuyenBayID)
        {
            List<GiaVe> listObjResults = new List<GiaVe>();
            try
            {
                BookFlightDataContext context = new BookFlightDataContext();
                listObjResults = context.GiaVes.Where(p => p.ChuyenBayID == chuyenBayID).ToList();

            }
            catch { }
            return listObjResults;
        }

      
    }
}
